//package com.baizhi.filter;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//
//import java.io.IOException;
//
//public class MyFileter implements Filter {
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//
//        HttpSession session=((HttpServletRequest)servletRequest).getSession();
//        System.out.println("执行了强制登录");
//        if(session.getAttribute("admin")!=null){
//            filterChain.doFilter(servletRequest,servletResponse);
//        }else{
//            ((HttpServletResponse)servletResponse).sendRedirect(((HttpServletRequest)servletRequest).getContextPath()+"/login.jsp");
//        }
//    }
//}
